//
// Created by 张玭 on 24-6-13.
//
#include <string>
#include <iostream>

using namespace std;
struct Hero {
    string name;
    int age;
    bool sex;
};

void bubbleSort(struct Hero heroArray[], int len) {
    for (int i = 0; i < len - 1; ++i) {
        for (int j = 0; j < len - 1 - i; ++j) {
            if (heroArray[j].age > heroArray[j + 1].age) {
                struct Hero temp = heroArray[j];
                heroArray[j] = heroArray[j + 1];
                heroArray[j + 1] = temp;
            }
        }
    }
}

void printHero(struct Hero heroArray[], int len) {
    for (int i = 0; i < len; ++i) {
        cout << "姓名：" << heroArray[i].name << " 年龄：" << heroArray[i].age
             << " 性别：" << heroArray[i].sex << endl;
    }
}

int main() {
    struct Hero heroArray[5] = {
            {"关羽", 32, true},
            {"刘备", 33, true},
            {"张飞", 29, true},
            {"吕布", 23, true},
            {"貂蝉", 21, false}

    };
    int len = sizeof(heroArray) / sizeof(heroArray[0]);
    bubbleSort(heroArray, len);
    printHero(heroArray, len);

}